package com.ideaaedi.log4j2.defender.properties;

import com.ideaaedi.log4j2.defender.defender.DefaultRegexMessageDefender;
import com.ideaaedi.log4j2.defender.defender.Log4j2MessageDefender;
import com.ideaaedi.log4j2.defender.strategy.RegexDefenderStrategyProvider;
import org.apache.logging.log4j.core.LogEvent;

import java.util.ArrayList;
import java.util.List;

/**
 * 正则脱敏配置项
 *
 * @author JustryDeng
 * @since 2021/7/21 1:15:15
 */
public class DefaultRegexProperties {
    
    /**
     * 正则脱敏策略提供者
     */
    private RegexDefenderStrategyProvider strategyProvider;
    
    /**
     * 指定短路插件
     * <p>
     *     当shortCircuitPlugins中存在{@link Log4j2MessageDefender#support(LogEvent)}匹配的插件时，
     *     使用该插件进行脱敏，而不用脱敏器进行脱敏
     * </p>
     */
    private List<Log4j2MessageDefender> shortCircuitPlugins = new ArrayList<>();
    
    public RegexDefenderStrategyProvider getStrategyProvider() {
        return strategyProvider;
    }
    
    public void setStrategyProvider(RegexDefenderStrategyProvider strategyProvider) {
        this.strategyProvider = strategyProvider;
    }
    
    public List<Log4j2MessageDefender> getShortCircuitPlugins() {
        return shortCircuitPlugins;
    }
    
    public void setShortCircuitPlugins(List<Log4j2MessageDefender> shortCircuitPlugins) {
        this.shortCircuitPlugins = shortCircuitPlugins;
    }
    
    @Override
    public String toString() {
        return "DefaultRegexProperties{" +
                "strategyProvider=" + strategyProvider +
                '}';
    }
}